const { NotExtended } = require("http-errors")
const mysql = require("mysql")

const connectObj = mysql.createConnection({
    host:"localhost",
    port:"3306",
    user:"root",
    password:"root",
    database:"u_class"
})

// 封装
function query(sql=''){
    return new Promise(resolve=>{
        connectObj.query(sql,(err,result)=>{
            if(err){
                console.log(err);
                return;
            }
            resolve(result);
        })
    })
}

module.exports = query;